﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.Mvc;
using System.ComponentModel.DataAnnotations;

namespace ElectrosLTD.Models
{
    public class RegistrationModel
    {
        [Required(ErrorMessage = "Name is required")]
        public string Name { get; set; }
        [Required(ErrorMessage = "Surname is required")]
        public string Surname { get; set; }

        [Required(ErrorMessage = "HouseNo is required")]
        public string HouseNo { get; set; }
        [Required(ErrorMessage = "Street is required")]
        public string Street { get; set; }
        [Required(ErrorMessage = "PostCode is required")]
        public string Postcode { get; set; }
        [Required(ErrorMessage = "Town is required")]
        public string Town { get; set; }
        public int countryID { get; set; }

        [Required(ErrorMessage = "Email is required")]
        [DataType(DataType.EmailAddress, ErrorMessage = "Incorrect Email format!")]
        [RegularExpression(@"[a-z0-9._%+-]+@[a-z0-9.-]+\.[a-z]{2,4}", ErrorMessage = "Please enter correct email!")]
        [Remote("DoesEmailExists", "User", ErrorMessage = "Email already registered!")]
        public string Email { get; set; }
        [Required(ErrorMessage = "Mobile is required")]
        public int Mobile { get; set; }

        [Required(ErrorMessage = "Username is required")]
        [Remote("DoesUsernameExists", "User", ErrorMessage = "Username already registered!")]
        public string username { get; set; }
        [Required(ErrorMessage = "Password is required")]
        public string password { get; set; }

        public IEnumerable<SelectListItem> countryList { get; set; }


        public RegistrationModel()
        {
            countryList = new SelectList(new UserServ.UserWCFClient().GetCountries(), "ID", "Name");
        }
    }
}